package band.wukong.practice.springboot.util.test;

import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;

/**
 * MockHttpServletRequestBuilder json Utility
 *
 * @author wukong(wukonggg@139.com)
 */
public class RequestBuilderJsonUtil {

    private static final String URL_VARS_JSON = "json";
    private static final String ENCODING = "UTF-8";


    public static MockHttpServletRequestBuilder get(String url) {
        return MockMvcRequestBuilders
            .get(url, URL_VARS_JSON)
            .characterEncoding(ENCODING)
            .contentType(MediaType.APPLICATION_JSON);
    }

    public static MockHttpServletRequestBuilder post(String url) {
        return MockMvcRequestBuilders
            .post(url, URL_VARS_JSON)
            .characterEncoding(ENCODING)
            .contentType(MediaType.APPLICATION_JSON);
    }

    public static MockHttpServletRequestBuilder put(String url) {
        return MockMvcRequestBuilders
            .put(url, URL_VARS_JSON)
            .characterEncoding(ENCODING)
            .contentType(MediaType.APPLICATION_JSON);
    }

    public static MockHttpServletRequestBuilder delete(String url) {
        return MockMvcRequestBuilders
            .delete(url, URL_VARS_JSON)
            .characterEncoding(ENCODING)
            .contentType(MediaType.APPLICATION_JSON);
    }
}
